# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: tobias <tobias@arhlinux.org>

pkgname=exiv2
pkgver=0.27.4
pkgrel=2
pkgdesc="Exif, Iptc and XMP metadata manipulation library and tools"
url="https://exiv2.org"
arch=('x86_64')
license=('GPL2')
depends=('gcc-libs' 'zlib' 'expat' 'libexpat.so' 'gettext' 'curl' 'libcurl.so')
makedepends=('cmake' 'gtest' 'ninja')
checkdepends=('python')
provides=('libexiv2.so')
source=(https://github.com/Exiv2/exiv2/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz
        exiv2-gtest-1.11.patch::https://github.com/Exiv2/exiv2/commit/f01805f6.patch)
sha512sums=('08c76bd278b7576a85115d632181fe00d26ce9b6ed3e7594e62c79b865cb906d5f444ea43d5e680ca7bf3ac98b8bc5b4d31bdde58d4464a24169a21291617ed3'
            '3933ede5bcb851546e9723a29a8bc666eb2b2fe5f811297989ddbd20a592b4f05d294837844f942d0c4ccdadec83b25e0cf6ca2b1a095a39ace9478ee72bafbc')
b2sums=('f7a9ece0b2bf1b24f4b4f987f74e9ef38d48add1427ee5151856cd7db5cfbf131d755c16a69425eda721ea180e488fe2f4b42dc99dafe5fef1a60ae8dbe3b6fe'
        'f64dfefd76c4c74da330fab8313ea7ab09b5ab9c42b04e8acbdf870aa13d7e12f5d0e9eb495525bfdeb551d7eb63de69236afc06623a0f03281d4607d11d1b66')

prepare() {
  patch -d $pkgname-$pkgver -p1 < exiv2-gtest-1.11.patch # Fix build with gtest 1.11
}

build() {
  cd ${pkgname}-${pkgver}
  cmake -B build \
    -GNinja \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_SKIP_RPATH=ON \
    -DEXIV2_BUILD_SAMPLES=ON \
    -DEXIV2_BUILD_UNIT_TESTS=ON \
    -DEXIV2_ENABLE_VIDEO=ON \
    -DEXIV2_ENABLE_NLS=ON \
    -DEXIV2_ENABLE_XMP=ON \
    -DEXIV2_ENABLE_CURL=ON \
    -DEXIV2_ENABLE_WEBREADY=ON \
    -DEXIV2_ENABLE_BMFF=ON
  ninja -C build
}

check() {
  cd ${pkgname}-${pkgver}
  ninja -C build tests
}

package() {
  cd ${pkgname}-${pkgver}
  # remove samples instal which are only needed for unit tests
  sed '/samples\/cmake_install.cmake/d' -i build/cmake_install.cmake
  DESTDIR="${pkgdir}" ninja -C build install
}

# vim: ts=2 sw=2 et:
